<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>返回CSR的公钥</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.openssl-csr-get-public-key" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">openssl_csr_get_public_key</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.2.0, PHP 7)</p><p class="refpurpose"><span class="refname">openssl_csr_get_public_key</span> &mdash; <span class="dc-title">返回CSR的公钥</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.openssl-csr-get-public-key-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>openssl_csr_get_public_key</strong></span>
    ( <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$csr</code></span>
   [, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$use_shortnames</code><span class="initializer"> = true</span></span>
  ] ) : <span class="type">resource</span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>openssl_csr_get_public_key()</strong></span> 从<code class="parameter">csr</code>中提取公钥供其他功能使用。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.openssl-csr-get-public-key-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

     
 <dt>
<code class="parameter">csr</code></dt>

 <dd>

  <p class="para">
   See <a href="openssl.certparams.html" class="link">CSR parameters</a> for a list of valid values.
  </p>
 </dd>


    
     <dt>
<code class="parameter">use_shortnames</code></dt>

     <dd>

      <div class="warning"><strong class="warning">Warning</strong>
       <p class="para">
        该参数可以省略。
       </p>
      </div>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.openssl-csr-get-public-key-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功，返回一个私钥标识符，错误则返回FALSE. 
  </p>
 </div>

 
 <div class="refsect1 examples" id="refsect1-function.openssl-csr-get-public-key-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-925">
    <p><strong>Example #1 openssl_csr_get_public_key() example</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$subject&nbsp;</span><span style="color: #007700">=&nbsp;array(<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"commonName"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"example.com"</span><span style="color: #007700">,<br />);<br /></span><span style="color: #0000BB">$private_key&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">openssl_pkey_new</span><span style="color: #007700">(array(<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"private_key_bits"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">2048</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">"private_key_type"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">OPENSSL_KEYTYPE_RSA</span><span style="color: #007700">,<br />));<br /></span><span style="color: #0000BB">$csr&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">openssl_csr_new</span><span style="color: #007700">(</span><span style="color: #0000BB">$subject</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$private_key</span><span style="color: #007700">,&nbsp;array(</span><span style="color: #DD0000">'digest_alg'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'sha256'</span><span style="color: #007700">)&nbsp;);<br /></span><span style="color: #0000BB">$public_key&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">openssl_csr_get_public_key</span><span style="color: #007700">(</span><span style="color: #0000BB">$csr</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$info&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">openssl_pkey_get_details</span><span style="color: #007700">(</span><span style="color: #0000BB">$public_key</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">$info</span><span style="color: #007700">[</span><span style="color: #DD0000">'key'</span><span style="color: #007700">];<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.openssl-csr-get-public-key-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="openssl_csr_get_subject.html" class="function" rel="rdfs-seeAlso">openssl_csr_get_subject()</a> - 返回CSR的主题</span></li>
    <li class="member"><span class="function"><a href="openssl_csr_new.html" class="function" rel="rdfs-seeAlso">openssl_csr_new()</a> - 生成一个 CSR</span></li>
    <li class="member"><span class="function"><a href="openssl_pkey_get_details.html" class="function" rel="rdfs-seeAlso">openssl_pkey_get_details()</a> - 返回包含密钥详情的数组</span></li>
    <li class="member"><span class="function"><a href="openssl_pkey_export_to_file.html" class="function" rel="rdfs-seeAlso">openssl_pkey_export_to_file()</a> - 将密钥导出到文件中</span></li>
    <li class="member"><span class="function"><a href="openssl_pkey_export.html" class="function" rel="rdfs-seeAlso">openssl_pkey_export()</a> - 将一个密钥的可输出表示转换为字符串</span></li>
   
   </ul>
  </p>
 </div>

 
</div></div></div></body></html>